*** This do file makes event study graphs in Figure B1 for the minimum wage precommittment paper
*** using 2013 as the base year


set more off
capture log close
clear all
* If needed change global path to point to directory where files are stored on your computer
*global path "I:/DataSets5/Duncan/Dropbox/Recent Minimum Wage Changes/2020.12 NBER Update/JOLE Precommittment Replication"

global dtadir "$path/Data"
global tabdir "$path/Tables"
global figdir "$path/Figures"
global estdir "$path/Estimates"
global logdir "$path/Logfiles"


log using "$logdir/event-study-graphs-2013.log", replace


**** LOW-SKILLED INDIVIDUALS AGES 16-25 WITH LESS THAN A COMPLETED HIGH-SCHOOL EDUCATION


*** Panel A: Low-Skilled No Controls
use "$estdir/BaseYear2013/CalendarYearRegressionEmploymentLeastNoControls.dta", clear

* Manually add 0 for 2013 variables (2013) is the baseline period for the event study
replace parm = "StatIncreaserLarge_t_2013" if parm == "HPI" 
replace parm = "StatIncreaserSmall_t_2013" if parm == "lnPersonalIncome" 
replace parm = "indexer_t_2013" if parm == "_cons" 

replace estimate = 0 if parm == "StatIncreaserLarge_t_2013"
replace stderr = 0 if parm == "StatIncreaserLarge_t_2013"
replace min95 = 0 if parm  == "StatIncreaserLarge_t_2013"
replace max95 = 0 if parm  == "StatIncreaserLarge_t_2013"

replace estimate = 0 if parm == "StatIncreaserSmall_t_2013"
replace stderr = 0 if parm == "StatIncreaserSmall_t_2013"
replace min95 = 0 if parm  == "StatIncreaserSmall_t_2013"
replace max95 = 0 if parm  == "StatIncreaserSmall_t_2013"

replace estimate = 0 if parm == "indexer_t_2013"
replace stderr = 0 if parm == "indexer_t_2013"
replace min95 = 0 if parm  == "indexer_t_2013"
replace max95 = 0 if parm  == "indexer_t_2013"

** Generate year variable
gen year = substr(parm,-4,.)
destring year, replace

* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "StatIncreaserLarge"), year - 0.2, cond(strpos(parm, "indexer"), year + 0.2, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "indexer")
replace policygroup = 2 if strpos(parm, "StatIncreaserSmall")
replace policygroup = 3 if strpos(parm, "StatIncreaserLarge")

label define grouplbl 1 "Indexer" 2 "Small" 3 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 3, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 3, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 2, msymbol(square) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel A: Low-Skilled with No Controls", size(medsmall) color(black)) ///
	legend(order(1 3 5) label(1 "Large") label(3 "Small") label(5 "Indexer") rows(1) region(lstyle(none)) size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(2010(1)2019, labsize(small)) xscale(range(2010 2019)) ///
	name(CalendarYearLeastNoControls, replace)


*** Panel B: Low-Skilled Sparse Controls
use "$estdir/BaseYear2013/CalendarYearRegressionEmploymentLeastBaseControls.dta", clear

* Manually add 0 for 2013 variables (2013) is the baseline period for the event study
replace parm = "StatIncreaserLarge_t_2013" if parm == "HPI" 
replace parm = "StatIncreaserSmall_t_2013" if parm == "lnPersonalIncome" 
replace parm = "indexer_t_2013" if parm == "_cons" 

replace estimate = 0 if parm == "StatIncreaserLarge_t_2013"
replace stderr = 0 if parm == "StatIncreaserLarge_t_2013"
replace min95 = 0 if parm  == "StatIncreaserLarge_t_2013"
replace max95 = 0 if parm  == "StatIncreaserLarge_t_2013"

replace estimate = 0 if parm == "StatIncreaserSmall_t_2013"
replace stderr = 0 if parm == "StatIncreaserSmall_t_2013"
replace min95 = 0 if parm  == "StatIncreaserSmall_t_2013"
replace max95 = 0 if parm  == "StatIncreaserSmall_t_2013"

replace estimate = 0 if parm == "indexer_t_2013"
replace stderr = 0 if parm == "indexer_t_2013"
replace min95 = 0 if parm  == "indexer_t_2013"
replace max95 = 0 if parm  == "indexer_t_2013"

** Generate year variable
gen year = substr(parm,-4,.)
destring year, replace

* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "StatIncreaserLarge"), year - 0.2, cond(strpos(parm, "indexer"), year + 0.2, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "indexer")
replace policygroup = 2 if strpos(parm, "StatIncreaserSmall")
replace policygroup = 3 if strpos(parm, "StatIncreaserLarge")

label define grouplbl 1 "Indexer" 2 "Small" 3 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 3, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 3, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 2, msymbol(square) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel B: Low-Skilled with Sparse Controls", size(medsmall) color(black)) ///
	legend(order(1 3 5) label(1 "Large") label(3 "Small") label(5 "Indexer") rows(1) region(lstyle(none)) size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(2010(1)2019, labsize(small)) xscale(range(2010 2019)) ///
	name(CalendarYearLeastBaseControls, replace)

*** Panel C: Low-Skilled Rich Controls
use "$estdir/BaseYear2013/CalendarYearRegressionEmploymentLeastRichControls.dta", clear

* Drop unneded variables
drop if substr(parm,1,1) == "D"

* Manually add 0 for 2013 variables (2013) is the baseline period for the event study
replace parm = "StatIncreaserLarge_t_2013" if parm == "HPI" 
replace parm = "StatIncreaserSmall_t_2013" if parm == "lnPersonalIncome" 
replace parm = "indexer_t_2013" if parm == "_cons" 

replace estimate = 0 if parm == "StatIncreaserLarge_t_2013"
replace stderr = 0 if parm == "StatIncreaserLarge_t_2013"
replace min95 = 0 if parm  == "StatIncreaserLarge_t_2013"
replace max95 = 0 if parm  == "StatIncreaserLarge_t_2013"

replace estimate = 0 if parm == "StatIncreaserSmall_t_2013"
replace stderr = 0 if parm == "StatIncreaserSmall_t_2013"
replace min95 = 0 if parm  == "StatIncreaserSmall_t_2013"
replace max95 = 0 if parm  == "StatIncreaserSmall_t_2013"

replace estimate = 0 if parm == "indexer_t_2013"
replace stderr = 0 if parm == "indexer_t_2013"
replace min95 = 0 if parm  == "indexer_t_2013"
replace max95 = 0 if parm  == "indexer_t_2013"

* Generate year variable
gen year = substr(parm,-4,.)
destring year, replace

* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "StatIncreaserLarge"), year - 0.2, cond(strpos(parm, "indexer"), year + 0.2, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "indexer")
replace policygroup = 2 if strpos(parm, "StatIncreaserSmall")
replace policygroup = 3 if strpos(parm, "StatIncreaserLarge")

label define grouplbl 1 "Indexer" 2 "Small" 3 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 3, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 3, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 2, msymbol(square) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel C: Low-Skilled with Rich Controls", size(medsmall) color(black)) ///
	legend(order(1 3 5) label(1 "Large") label(3 "Small") label(5 "Indexer") rows(1) nobox size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(2010(1)2019, labsize(small)) xscale(range(2010 2019)) ///
	name(CalendarYearLeastRichControls, replace)

*** Panel D: Young No Controls
use "$estdir/BaseYear2013/CalendarYearRegressionEmploymentYoungNoControls.dta", clear

* Manually add 0 for 2013 variables (2013) is the baseline period for the event study
replace parm = "indexer_t_2013" if parm == "_cons" 

replace estimate = 0 if parm == "StatIncreaserLarge_t_2013"
replace stderr = 0 if parm == "StatIncreaserLarge_t_2013"
replace min95 = 0 if parm  == "StatIncreaserLarge_t_2013"
replace max95 = 0 if parm  == "StatIncreaserLarge_t_2013"

replace estimate = 0 if parm == "StatIncreaserSmall_t_2013"
replace stderr = 0 if parm == "StatIncreaserSmall_t_2013"
replace min95 = 0 if parm  == "StatIncreaserSmall_t_2013"
replace max95 = 0 if parm  == "StatIncreaserSmall_t_2013"

replace estimate = 0 if parm == "indexer_t_2013"
replace stderr = 0 if parm == "indexer_t_2013"
replace min95 = 0 if parm  == "indexer_t_2013"
replace max95 = 0 if parm  == "indexer_t_2013"

* Generate year variable
gen year = substr(parm,-4,.)
destring year, replace


* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "StatIncreaserLarge"), year - 0.2, cond(strpos(parm, "indexer"), year + 0.2, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "indexer")
replace policygroup = 2 if strpos(parm, "StatIncreaserSmall")
replace policygroup = 3 if strpos(parm, "StatIncreaserLarge")

label define grouplbl 1 "Indexer" 2 "Small" 3 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 3, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 3, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 2, msymbol(square) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel D: Young with No Controls", size(medsmall) color(black)) ///
	legend(order(1 3 5) label(1 "Large") label(3 "Small") label(5 "Indexer") rows(1) nobox size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(2010(1)2019, labsize(small)) xscale(range(2010 2019)) ///
	name(CalendarYearYoungNoControls, replace)

*** Panel E: Young Sparse  Controls
use "$estdir/BaseYear2013/CalendarYearRegressionEmploymentYoungBaseControls.dta", clear

* Manually add 0 for 2013 variables (2013) is the baseline period for the event study
replace parm = "StatIncreaserLarge_t_2013" if parm == "HPI" 
replace parm = "StatIncreaserSmall_t_2013" if parm == "lnPersonalIncome" 
replace parm = "indexer_t_2013" if parm == "_cons" 

replace estimate = 0 if parm == "StatIncreaserLarge_t_2013"
replace stderr = 0 if parm == "StatIncreaserLarge_t_2013"
replace min95 = 0 if parm  == "StatIncreaserLarge_t_2013"
replace max95 = 0 if parm  == "StatIncreaserLarge_t_2013"

replace estimate = 0 if parm == "StatIncreaserSmall_t_2013"
replace stderr = 0 if parm == "StatIncreaserSmall_t_2013"
replace min95 = 0 if parm  == "StatIncreaserSmall_t_2013"
replace max95 = 0 if parm  == "StatIncreaserSmall_t_2013"

replace estimate = 0 if parm == "indexer_t_2013"
replace stderr = 0 if parm == "indexer_t_2013"
replace min95 = 0 if parm  == "indexer_t_2013"
replace max95 = 0 if parm  == "indexer_t_2013"

* Generate year variable
gen year = substr(parm,-4,.)
destring year, replace


* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "StatIncreaserLarge"), year - 0.2, cond(strpos(parm, "indexer"), year + 0.2, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "indexer")
replace policygroup = 2 if strpos(parm, "StatIncreaserSmall")
replace policygroup = 3 if strpos(parm, "StatIncreaserLarge")

label define grouplbl 1 "Indexer" 2 "Small" 3 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 3, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 3, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 2, msymbol(square) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel E: Young with Sparse Controls", size(medsmall) color(black)) ///
	legend(order(1 3 5) label(1 "Large") label(3 "Small") label(5 "Indexer") rows(1) nobox size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(2010(1)2019, labsize(small)) xscale(range(2010 2019)) ///
	name(CalendarYearYoungBaseControls, replace)



*** Panel F: Young Rich Controls
use "$estdir/BaseYear2013/CalendarYearRegressionEmploymentYoungRichControls.dta", clear

* Drop unneded variables
drop if substr(parm,1,1) == "D"

* Manually add 0 for 2013 variables (2013) is the baseline period for the event study
replace parm = "StatIncreaserLarge_t_2013" if parm == "HPI" 
replace parm = "StatIncreaserSmall_t_2013" if parm == "lnPersonalIncome" 
replace parm = "indexer_t_2013" if parm == "_cons" 

replace estimate = 0 if parm == "StatIncreaserLarge_t_2013"
replace stderr = 0 if parm == "StatIncreaserLarge_t_2013"
replace min95 = 0 if parm  == "StatIncreaserLarge_t_2013"
replace max95 = 0 if parm  == "StatIncreaserLarge_t_2013"

replace estimate = 0 if parm == "StatIncreaserSmall_t_2013"
replace stderr = 0 if parm == "StatIncreaserSmall_t_2013"
replace min95 = 0 if parm  == "StatIncreaserSmall_t_2013"
replace max95 = 0 if parm  == "StatIncreaserSmall_t_2013"

replace estimate = 0 if parm == "indexer_t_2013"
replace stderr = 0 if parm == "indexer_t_2013"
replace min95 = 0 if parm  == "indexer_t_2013"
replace max95 = 0 if parm  == "indexer_t_2013"

* Generate year variable
gen year = substr(parm,-4,.)
destring year, replace


* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "StatIncreaserLarge"), year - 0.2, cond(strpos(parm, "indexer"), year + 0.2, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "indexer")
replace policygroup = 2 if strpos(parm, "StatIncreaserSmall")
replace policygroup = 3 if strpos(parm, "StatIncreaserLarge")

label define grouplbl 1 "Indexer" 2 "Small" 3 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 3, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 3, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 2, msymbol(square) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel F: Young with Rich Controls", size(medsmall) color(black)) ///
	legend(order(1 3 5) label(1 "Large") label(3 "Small") label(5 "Indexer") rows(1) nobox size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(2010(1)2019, labsize(small)) xscale(range(2010 2019)) ///
	name(CalendarYearYoungRichControls, replace)


* Combine graphs to make a 6-panel figure
set graph on
graph dir // These named graphs are now in memory


grstyle init
grstyle color background white
*grstyle graphsize x 8
*grstyle graphsize y 7
grstyle set legend, nobox


* Combined employment graph
grc1leg2 CalendarYearLeastNoControls CalendarYearLeastBaseControls CalendarYearLeastRichControls ///
	CalendarYearYoungNoControls CalendarYearYoungBaseControls CalendarYearYoungRichControls,  ///
	l1("Change", size(medsmall) color(black)) b1("Calendar Time", size(medsmall) color(black)) ring(2) xsize(20) ysize(11) margins(tiny)  ///
	legendfrom(CalendarYearLeastBaseControls) lsize(medsmall) graphregion(color(white)) rows(2)
graph export "$figdir/calendar-time-event-study-figure.pdf", as(pdf) replace
